#{extends 'CRUD/layout.html' /}
#{set title:messages.get('complaintTypes.edit') /}

<div id="crudShow" class="${type.name}">

    <h2 id="crudShowTitle">&{'complaintTypes.edit'}</h2>

    <div class="objectForm">
    #{form action:@save(object._key()), enctype:'multipart/form-data'}
        #{crud.form fields:['complaintTypeName', 'multyplier', 'syndrome', 'complaints'] }
			#{crud.custom 'syndrome'}
        	   <label for="${syndrome}">&{'syndrome'}</label>
		       #{select 'object.syndrome.syndromeId', items:models.Syndrome.findAll(), valueProperty:'syndromeId', 
		       		labelProperty:'name', value:object.syndrome.syndromeId, id:'syndromeSelector' /}
        	#{/crud.custom}
        	
        	#{crud.custom 'complaints'}
	    		<label for="${complaints}"><a href="@{Complaints.list()}" class="nonUnderlined">&{'objects.complaints'}</a></label>
	    		%{complaints = models.Complaint.find("byComplaintType", object).fetch()}%
	    		#{if complaints != null && !complaints.isEmpty() }
	    		<div class="list">
					#{list items:complaints, as:'complaint'}
						<li>
							<span id="${complaint.complaintId}" class="hiddenLinks">
								@{Complaints.show(complaint.complaintId)}
					        </span>
					        ${complaint.complaintName}
				        </li>
				    #{/list}
	    		</div>
	    		#{/if}
	    		#{else}
					&{'crud.list.empty'}	    		
	    		#{/else}
        	#{/crud.custom}
        #{/crud.form}
        <p class="crudButtons">
            <input type="submit" name="_save" value="&{'crud.save', type.modelName}" />
            <input type="submit" name="_saveAndContinue" value="&{'crud.saveAndContinue', type.modelName}" />
        </p>
    #{/form}
    </div>

    #{form @delete(object._key())}
        <p class="crudDelete">
            <input type="submit" value="&{'complaintTypes.delete'}" onclick="return confirm('&{'complaintTypes.delete'}')"/>
        </p>
    #{/form}

</div>